package com.cloudsigns.factorymanager2.produce.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.produce.activity.ProduceOutsourcingListActivity;
import com.cloudsigns.factorymanager2.produce.activity.ProduceConfigurationPersonnelListActivity;
import com.cloudsigns.factorymanager2.produce.activity.ProduceDispatchOrderListActivity;
import com.cloudsigns.factorymanager2.produce.activity.ProduceEditOrderListActivity;
import com.cloudsigns.factorymanager2.produce.activity.ProduceEngineeringUseActivity;
import com.cloudsigns.factorymanager2.produce.activity.ProduceReceiveOrderFragmentActivity;

public class ProduceOrderFragment extends Fragment implements View.OnClickListener {
    private RelativeLayout rl_receive_order, rl_edit_order, rl_assigned_order, /*rl_engineering_recipients, rl_inventory_query*/
            rl_configuration_personnel, rl_produce_recipients, rl_production_outsourcing, rl_production_budget;


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_produce_order, null);
        rl_receive_order = view.findViewById(R.id.rl_receive_order);
        rl_edit_order = view.findViewById(R.id.rl_edit_order);
        rl_assigned_order = view.findViewById(R.id.rl_assigned_order);
        rl_configuration_personnel = view.findViewById(R.id.rl_configuration_personnel);
        rl_produce_recipients = view.findViewById(R.id.rl_produce_recipients);
        rl_production_outsourcing = view.findViewById(R.id.rl_production_outsourcing);
        rl_production_budget = view.findViewById(R.id.rl_production_budget);

        rl_receive_order.setOnClickListener(this);
        rl_edit_order.setOnClickListener(this);
        rl_assigned_order.setOnClickListener(this);
        rl_configuration_personnel.setOnClickListener(this);
        rl_produce_recipients.setOnClickListener(this);
        rl_production_outsourcing.setOnClickListener(this);
        rl_production_budget.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View view) {
        Intent mIntent;
        switch (view.getId()) {
            // 接收工单
            case R.id.rl_receive_order:
                mIntent = new Intent(getActivity(), ProduceReceiveOrderFragmentActivity.class);
                startActivity(mIntent);
                break;
            // 编辑工单
            case R.id.rl_edit_order:
                mIntent = new Intent(getActivity(), ProduceEditOrderListActivity.class);
                startActivity(mIntent);
                break;
            // 分派工单
            case R.id.rl_assigned_order:
                mIntent = new Intent(getActivity(), ProduceDispatchOrderListActivity.class);
                startActivity(mIntent);
                break;
//            // 工程领用
//            case R.id.rl_engineering_recipients:
//                mIntent=new Intent(getActivity(),ProduceEngineeringUseActivity.class);
//                startActivity(mIntent);
//                break;
//            // 库存查询
//            case R.id.rl_inventory_query:
//                break;
            // 配置人员
            case R.id.rl_configuration_personnel:
                    mIntent = new Intent(getActivity(), ProduceConfigurationPersonnelListActivity.class);
                startActivity(mIntent);
                break;
            // 生产领用
            case R.id.rl_produce_recipients:
                mIntent=new Intent(getActivity(),ProduceEngineeringUseActivity.class);
                startActivity(mIntent);
                break;
            // 生产外协
            case R.id.rl_production_outsourcing:
                mIntent = new Intent(getActivity(), ProduceOutsourcingListActivity.class);
                startActivity(mIntent);
                break;
            // 生产预算
            case R.id.rl_production_budget:
                break;
        }
    }
}
